Expand description
Simply call prompt
, prompt_default
, or prompt_opt
to prompt for any Promptable
type:
Examples
use promptly::{prompt, prompt_opt, prompt_default};
// Prompt until a non-empty string is provided
let name: String = prompt("Enter your name")?;
// Prompt for other `FromStr` types
let age: u32 = prompt("Enter your age")?;
// Prompt for optional paths with path completion. Returns `None` if empty input.
let photo: Option<PathBuf> = prompt_opt("Enter a path to a profile picture")?;
// Prompt Y/n with a default value when input is empty
let fallback = prompt_default("Would you like to receive marketing emails", true)?;
Enums
The error type for Rustyline errors that can arise from I/O related errors or Errno when using the nix-rust library
Traits
A trait for convenient, opinionated prompting
Functions
Prompt until input can be parsed as T
.
Prompt until input can be parsed as T
, returning the default
for empty input.
Prompt until input can be parsed as T
, returning None
for empty input.